import socket
import subprocess

r = socket.socket()
adress = ("127.0.0.1",8000)
r.connect(adress)

while True:
    i = input("输入：")
    if i == "exit":
        break
    r.send(bytes(i,"utf8")) #传输要用二进制
    data_len = int(str(r.recv(1024),"utf8"))
    print(data_len)
    data = bytes()
    while len(data) != data_len:
        recv = r.recv(1024)
        data += recv
    print(str(data,"gbk"))
r.close()